package com.code.vo;

public class PageVO {
	
	/**
	 * 总条数
	 */
	private int totalRow = 0;
	
	/**
	 * 每页条数
	 */
	private int pageRow = 10;
	
	/**
	 * 当前页码
	 */
	private int curPage = 1;
	
	/**
	 * 总页数
	 */
	private int totalPage = 0;
	
	/**
	 * 起始条
	 */
	private int beginRow = 0;
	
	/**
	 * 终止条
	 */
	private int endRow = 0;
	
	
	public int getTotalRow() {
		return totalRow;
	}
	
	public void setTotalRow(int totalRow) {
		this.totalRow = totalRow;
	}
	
	public int getPageRow() {
		return pageRow;
	}
	
	public void setPageRow(int pageRow) {
		if (pageRow <= 0)
			pageRow = 1;
		
		this.pageRow = pageRow;
	}
	
	public int getCurPage() {
		return curPage;
	}
	
	public void setCurPage(int curPage) {
		if (curPage <= 0)
			curPage = 1;
		
		this.curPage = curPage;
	}
	
	public void setCurPage(int start, int limit) {
		this.curPage = start / limit + 1;
	}
	

	public int getBeginRow() {
		beginRow = (curPage - 1) * pageRow;
		return beginRow;
	}

	public int getEndRow() {
		endRow = beginRow + pageRow;
		return endRow;
	}

	public int getTotalPage() {
		if (totalRow % pageRow == 0) {
			totalPage = totalRow / pageRow;
		} else {
			totalPage = totalRow / pageRow + 1;
		}
		
		return totalPage;
	}
	
	public void setTotalPage(int totalPage) {
		this.totalPage = totalPage;
	}
	
	public String pageMessage() {
		return "总条数 : " + totalRow + " --- 总页数 : " + totalPage + " --- 每页条数 : " + pageRow + " --- 当前页码 : " + curPage;
	}
	
}
